<?php
/*
 * @o: ========================================================
 * @Created By: VsCode
 * @Author: Fu
 * @name: 管理员控制器
 * @LastEditTime: 2021-05-13 09:15:04
 * @Date: 2021-05-10 16:36:37
 * @u: ========================================================
 */

namespace app\admin\model\goods;

use think\Model;
use app\admin\model\OrderChild;
use app\admin\model\goods\Goods_category;
class Goods extends Model
{

    // 表名
    protected $name = 'goods';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    protected $resultSetType = 'collection';

    // 追加属性
    protected $append = [
    ];
    public function getList($field)
    {
        $list =  $this->field($field)->select();
        return $list;
    }

    public function ordercount()
    {
        return $this->hasMany(OrderChild::class,'goods_id','id');
    }


    //链表查询
    public function goodsCategory()
    {
        return $this->belongsTo(Goods_category::class, 'goods_category_id')->setEagerlyType(0);//第2个参数是外键id
    }



}
